package com.acme.bankapp;

import java.io.*;
import java.net.Socket;
import java.net.UnknownHostException;

/**
 * @author Gregory Sobko
 */
public class BankClientApp {
    public static void main(String[] args) {
        try(Socket clientSocket = new Socket("127.0.0.1",BankServerApp.PORT);
            BufferedReader reader = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
            BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(clientSocket.getOutputStream()));
            BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in))
        ) {
            String userInput;
            String response;
            while ((userInput = stdIn.readLine()) != null) {
                writer.write(userInput);
                writer.newLine();
                writer.flush();
                response = reader.readLine();
                System.out.println("server: " + response );

            }
        }catch (IOException e) {
            e.printStackTrace();
        }

    }
}
